from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include

from music import views

# 主路由
urlpatterns = [
    path('grappelli/', include('grappelli.urls')),  # 后台
    path('admin/', admin.site.urls),  # 后台
    path('', views.home),  # 首页，检查登录状态
    path('all/', views.all),  # 全部音乐列表
    path('recommend', views.recommend),  # 推荐
    path('sign_in', views.sign_in),  # 登录
    path('sign_up', views.sign_up),  # 注册
    path('logout', views.user_logout),  # 退出
    path('captcha_image', views.captcha_image),  # 验证码图片
    path('like/<int:pk>', views.like),  # 喜欢
    path('dislike/<int:pk>', views.dislike),  # 不喜欢
    path('play', views.play),  # 播放
    path('play/<int:pk>', views.play),  # 播放
    path('user', views.user_center),  # 用户中心
    path('search', views.search),  # 搜索
    path('test_music_url/<int:pk>', views.test_music_url),  # 测试音乐URL
    
    # 音乐评分和评论相关路由
    path('music/<int:pk>', views.music_detail, name='music_detail'),  # 音乐详情
    path('music/<int:pk>/rate/', views.rate_music, name='rate_music'),  # 评分
    path('music/<int:pk>/comment/', views.add_comment, name='add_comment'),  # 评论
    path('comment/<int:comment_id>/reply/', views.reply_comment, name='reply_comment'),  # 回复评论
    
    # 播放历史相关路由
    path('history/', views.play_history, name='play_history'),  # 播放历史列表
]

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
